#include "MagicExSet.h"
#include <assert.h>

CMagicExSet::~CMagicExSet()
{
	for (int i = 0; i < m_vecMagic.size(); i++)
	{
		delete m_vecMagic[i];
	}

	m_vecMagic.clear();
}

void CMagicExSet::Load()
{
	//
	S_MAGICDATA_DB* pMagicData = new S_MAGICDATA_DB;
	assert(pMagicData);

	memset((void*)pMagicData, 0, sizeof(S_MAGICDATA_DB));

	pMagicData->usType = 1;
	pMagicData->ucLevel = 1;
	pMagicData->nUseMagic = 20;
	pMagicData->ucTargetType = E_ENEMY_MAGIC_TARGET;
	pMagicData->ucDamageType = E_PHY_DAMAGE;
	pMagicData->ucLaunchType = E_ACTIVE_MAGIC_LAUNCH;
	pMagicData->ucTargetMaxCount = 5;
	pMagicData->unDistance = 400;

	pMagicData->nIntoneTime = 2000; //ms
	pMagicData->nCDTime = 4000;

	pMagicData->ucRangeType = E_LINE_MAGIC_RANGE;
	pMagicData->nRangeParam1 = 100;

	pMagicData->magicActions[0].ucMainType = E_MOVE_MAGIC_ACTION;
	pMagicData->magicActions[0].ucSubType = 0;
	pMagicData->magicActions[0].ucActors = E_LAUNCHER_ACTOR;

	pMagicData->magicActions[1].ucMainType = E_TIMER_MAGIC_ACTION;
	pMagicData->magicActions[1].ucSubType = 0;
	pMagicData->magicActions[1].ucActors = E_LAUNCHER_ACTOR;
	pMagicData->magicActions[1].unParam1 = 5000;
	pMagicData->magicActions[1].unParam2 = 1000;

	pMagicData->magicActions[2].ucMainType = E_ATTACK_MAGIC_ACTION;
	pMagicData->magicActions[2].ucSubType = 0;  //xue
	pMagicData->magicActions[2].ucActors = E_ALL_TARGET_ACTOR;
	pMagicData->magicActions[2].unParam1 = 100;

	m_vecMagic.push_back(pMagicData);
}

S_MAGICDATA_DB* CMagicExSet::GetMagic(unsigned short usType, unsigned char ucLevel)
{
	S_MAGICDATA_DB* pMagicData = NULL;

	for (int i = 0; i < m_vecMagic.size(); i++)
	{
		pMagicData = m_vecMagic[i];
		if (pMagicData && pMagicData->usType==usType && pMagicData->ucLevel==ucLevel)
		{
			return pMagicData;
		}
	}

	return NULL;
}